package com.itjin.health.config;

import com.aliyun.oss.OSS;
import com.aliyun.oss.OSSClientBuilder;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class OssConfig {

    // 从配置文件中注入 endpoint
    @Value("${alibaba.cloud.oss.endpoint}")
    private String endpoint;

    // 从配置文件中注入 accessKey
    @Value("${alibaba.cloud.oss.access-key}")
    private String accessKeyId;

    // 从配置文件中注入 secretKey
    @Value("${alibaba.cloud.oss.secret-key}")
    private String accessKeySecret;

    // 创建 OSS 客户端 Bean
    @Bean
    public OSS ossClient() {
        return new OSSClientBuilder().build(endpoint, accessKeyId, accessKeySecret);
    }
}